package com.zzl.finance.order.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.zzl.apidoc.annotation.ApidocModel;
import com.zzl.apidoc.annotation.ApidocModelProperty;
import com.zzl.finance.order.dto.KeyValue;
import com.zzl.general.common.utils.DoubleSerialize;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author sunpp
 * @date 2021-11-26 19:40:12
 */
@Data
@TableName("o_order")
@ApidocModel
public class OrderEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.UUID)
    @ApidocModelProperty(description = "主键")
    private String id;
    @ApidocModelProperty(description = "订单编号")
    private String orderNo;
    @ApidocModelProperty(description = "凭证编号")
    private String ticketNo;
    @ApidocModelProperty(description = "融资编号")
    private String financeNo;
    @ApidocModelProperty(description = "订单类型 1：融资服务费，2：购买产品")
    private Integer orderType;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "订单总金额")
    private Double orderAmount;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "融资成本/ 融资本金")
    private Double sellAmount;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "服务费用")
    private Double serviceChage;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "利息费用")
    private Double estimatedFinancingInterest;

    @ApidocModelProperty(description = "订单状态，1：已支付、2：未支付")
    private Integer orderStatus;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApidocModelProperty(description = "更新时间", validate = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApidocModelProperty(description = "创建时间", validate = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    @ApidocModelProperty(description = "创建人id")
    private Integer creatorId;
    @ApidocModelProperty(description = "更新人id")
    private Integer updaterId;
    @ApidocModelProperty(description = "备注")
    private String remark;
    @ApidocModelProperty(description = "企业id")
    private String enterpriseId;
    @ApidocModelProperty(description = "组织机构id 控制数据权限")
    private Integer orgId;

    @ApidocModelProperty(description = "1 表示删除，0 表示未删除")
    @TableField(value = "is_deleted", fill = FieldFill.INSERT)
    @TableLogic(value = "0", delval = "1")
    private Integer isDeleted;

    @ApidocModelProperty(description = "金融机构id")
    private Integer instinctyId;

    @ApidocModelProperty(description = "金融名称")
    private String instinctyName;

    @ApidocModelProperty(description = "上联地址")
    private String chainAddress;

    @ApidocModelProperty(description = "发票状态  1已开票 2申请中 3已作废")
    private Integer invoiceStatus;

    @ApidocModelProperty(description = "融资企业id")
    private String financeEnterpriseId;

    @ApidocModelProperty(description = "融资企业名称")
    private String financeEnterpriseName;

    @ApidocModelProperty(description = "服务费率")
    private BigDecimal serviceRate;

    @ApidocModelProperty(description = "融资信息json")
    private String financeJson;

    @ApidocModelProperty(description = "融资申请id")
    private String financeId;

    @ApidocModelProperty(description = "付款企业id")
    private String paymentEnterpriseId;

    @ApidocModelProperty(description = "付款企业名称")
    private String paymentEnterpriseName;

    @ApidocModelProperty(description = "开立凭证编号")
    private String ticketOriginNo;

    @ApidocModelProperty(description = "     * 付息方式 ：\n" +
            "     1 融资方付息（默认）\n" +
            "     2 核心企业付息")
    private Integer paymentMode;

    @ApidocModelProperty(description = "预计到账金额")
    private BigDecimal estimatedReceivedAmount;

    @ApidocModelProperty(description = "融资成本")
    private BigDecimal financeCost;

    @ApidocModelProperty(description = "融资利息")
    private BigDecimal financeInterest;

    @ApidocModelProperty(description = "年化利率")
    private BigDecimal annualizedInterestRate;

    @ApidocModelProperty(description = "订单状态字符串")
    @TableField(exist = false)
    private String orderStatusStr;

    @ApidocModelProperty(description = "订单类型字符串")
    @TableField(exist = false)
    private String orderTypeStr;

    @TableField(exist = false)
    @ApidocModelProperty(description = "发票状态字符类型")
    private String invoiceStatusStr;

    @TableField(exist = false)
    @ApidocModelProperty(description = "操作按钮集合")
    private List<KeyValue> operateButton = new ArrayList<>();
}
